import java.util.*;

class Student {
    private String id;

    public Student() {

    }
    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                '}';
    }

    public Student(String id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(id, student.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}
public class Test {
    public static void main(String[] args) {
        Student student1 = new Student("1234");
        System.out.println(student1.hashCode());
        Student student2 = new Student("1234");
        System.out.println(student2.hashCode());
        HashBuck2<Student,String> hashBuck2 = new HashBuck2<>();
        hashBuck2.put(student1,"wangwu" );
        String ret = hashBuck2.get(student2);
        System.out.println(ret);
    }
    public static void main5(String[] args) {
        Student student1 = new Student("1234");
        System.out.println(student1.hashCode());
        Student student2 = new Student("1234");
        System.out.println(student2.hashCode());
    }
    public static void main4(String[] args) {
        HashBuck hashBuck = new HashBuck();

        hashBuck.put(1,11);
        hashBuck.put(2,22);
        hashBuck.put(3,33);
        hashBuck.put(4,44);
        hashBuck.put(5,55);
        hashBuck.put(6,66);
        hashBuck.put(7,77);



        Integer val = hashBuck.get(5);
        System.out.println(val);
    }

    public static void main3(String[] args) {
        Set<String> set1 = (Set<String>) new TreeSet();
        set1.add("hello");
        set1.add("asd");
        set1.add("hello");
        System.out.println(set1);
    }
    public static void main2(String[] args) {
        Map<Student,Integer>  treeMap = new TreeMap<>();
        //key一定是可以比较的
        treeMap.put(new Student(),1);
        treeMap.put(new Student(),4);
        treeMap.put(new Student(),5);
        System.out.println(treeMap);

    }
    public static void main1(String[] args) {
        Map<String,Integer> treeMap = new TreeMap<>();
        treeMap.put("hello",3);
        treeMap.put("abc",4);
        treeMap.put("thr",5);
        System.out.println(treeMap);
        Integer val = treeMap.getOrDefault("hello2",100);
        System.out.println(val);
        Set<String> keySet = treeMap.keySet();
        System.out.println(keySet);
        Set<Map.Entry<String,Integer>> set = treeMap.entrySet();
        for (Map.Entry<String,Integer> entry:set) {
            System.out.println("key:"+entry.getKey() +" value:" + entry.getKey());
        }

    }
}
